#include <cpptest.h>
#include <map>
#include <map>
#include <string>
#include "unit_tests.hpp"
#include "connection.hpp"

/*
 * \brief Unit test for the connection.hpp
 */
void ConnectionTest::test_connection()
{
    Connection player1;
    Connection player2;
    std::map<std::string,std::string> messageToSend;
    std::map<std::string,std::string> messageToRecieve;

    // Takes IP for connection and port
    player1.create("127.0.0.1", 432);
    player2.join("127.0.0.1", 432);
   
    // Create a message from a map<string, string>
    // Here is an example of moving using degrees as direction
    // And distance as in inches
    messageToSend["action"] = "move";
    messageToSend["degrees"] = "220";
    messageToSend["distance"] = "3";

    // These are the two functions for getting and recieving
    player1.send(messageToSend);
    player1.recieve(messageToRecieve);
    // Tests to see if it works!
    TEST_ASSERT(messageToRecieve["action"] == "move");
    TEST_ASSERT(messageToRecieve["degrees"] == "220");
    TEST_ASSERT(messageToREcieve["distance"] == "3");
}


